import org.apache.spark.{SparkConf, SparkContext}

import scala.util.parsing.json.JSON

object JSONApp {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setAppName("JSONParse").setMaster("local")
    conf.set("spark.testing.memory", "2147480000")
    val sc = new SparkContext(conf)
    val jsRdd = sc.textFile("src/jsonfile")
    val result = jsRdd.map(x => JSON.parseFull(x))
    result.foreach({ x => x match {
      case Some(map : Map[String,Any]) => println(map)
      case None => println("Parsing failed")
      case other => println("Unknow data structure: "+other)
    }

    })
  }

}
